'use strict';
//已提现列表
import React,{Component} from 'react';
import Header from '../../common/header';
import * as URLconstant from '../../constant/URLconstant'
import Util from '../../common/util';
import {
    View,
    Text,
    TouchableOpacity,
    Image,
    StyleSheet,
    ScrollView
} from 'react-native';
export default class cashOutList extends Component{
    // 构造
      constructor(props) {
        super(props);
        // 初始状态
        this.state = {
            outList:null
        };
      }

    componentDidMount() {
        this.getCashList()
    }

      getCashList(){
          let url = URLconstant.CASH_OUT_LIST
          let datakey=[]
          datakey['user_id']=this.props.user_id
          Util.get(url,datakey,this.getListSuc.bind(this),this.errorCallback.bind(this))
      }

    getListSuc(datas){
        if(datas.status==0){
            this.setState({
                outList:datas.data.list
            })
        }else{
            this.setState({
                outList:[]
            })
        }
    }
    errorCallback(err){

    }

      render(){
          let outList = this.state.outList
          return(
              <View style={{flex:1,backgroundColor:"#f0f0f0"}}>
                  <Header navigator={this.props.navigator} initObj={{ title: '已提现列表',id:2}}/>
                  {
                      outList==null?
                          <View style={{flex:1}}>
                              {Util.loading()}
                          </View>
                          :
                          <View style={{flex:1}}>
                              {
                                  outList.length==0?
                                      <View style={{flex:1, alignItems:'center',justifyContent:'center'}}>
                                          <Text>没有提现记录</Text>
                                      </View>
                                      :
                                      <ScrollView style={{flex:1}}>
                                          {
                                              outList.map((item,index)=>{
                                                  return(
                                                      <View style={styles.list_item} key={index}>
                                                          <View style={styles.txt_view}>
                                                              <Text style={styles.item_txt}>提现单号:{item.id}</Text>
                                                          </View>
                                                          <View style={styles.txt_view}>
                                                              <Text style={styles.item_txt}>订单金额:</Text>
                                                              <Text style={{fontSize:12,color:"#ff5000",marginLeft:5}}>¥{item.price}</Text>
                                                          </View>
                                                          <View style={styles.txt_view}>
                                                              <Text style={styles.item_txt}>提现时间:{item.add_time}</Text>
                                                          </View>
                                                          {
                                                              item.status==1?
                                                                  <View style={styles.txt_view}>
                                                                      <Text style={styles.item_txt}>提现状态:已提现</Text>
                                                                  </View>
                                                                  :
                                                                  <View style={styles.txt_view}>
                                                                      <Text style={styles.item_txt}>提现状态:待审核</Text>
                                                                  </View>
                                                          }

                                                      </View>
                                                  )
                                              })
                                          }
                                      </ScrollView>
                              }
                          </View>
                  }
              </View>
          )
      }
}
var styles = StyleSheet.create({
    list_item:{
        paddingVertical:7,
        paddingHorizontal:10,
        marginBottom:10,
        backgroundColor:"#fff"
    },
    txt_view:{
        height:20,
        flexDirection:'row',
        alignItems:'center'
    },
    item_txt:{
        fontSize:12,
        color:"#333"
    },
})